package in.muton.edushare.pages.coursepages;

import in.muton.edushare.pages.univ.UnivPage;
import in.muton.edushare.processing.objects.CourseDataHandler;
import in.muton.edushare.url.EntityPageParams;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.panels.paginator.EntityListing;

import org.apache.wicket.PageParameters;
import org.apache.wicket.RestartResponseAtInterceptPageException;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.vo.Universities;

public class CourseUniv extends CourseBase {

	public CourseUniv(PageParameters params) {
		super(params);
		CayenneList<Universities> cL = new CourseDataHandler(
				getCourseInstance()).getUnivs();
		if (cL.getObject().size() == 1) {
			UnivPage p = new UnivPage(EntityPageParams.getParams(cL.getObject()
					.get(0)));
			throw new RestartResponseAtInterceptPageException(p);
		}
		add(new EntityListing<Universities>("thumbList", cL, this));
	}

	@Override
	protected String getActivePage(PageParameters params) {
		return "courseUniv";
	}

	@Override
	public String getPageTitle() {
		return getLoggedInUser().getCompleteUserName() + " | "
				+ getCourse().getObject().getCourseName()
				+ " | Universities | " + ApplicationConstants.APPLICATION_NAME;
	}

}
